import requests
import random
cookies = {
    'buvid3': 'BD9B8A8A-BEFB-3F7B-F3EA-BE16097BEC6341653infoc',
    'b_nut': '1714358241',
    '_uuid': 'BDD696FA-F8103-CD102-E6A3-110DA8589D43E41961infoc',
    'enable_web_push': 'DISABLE',
    'buvid4': '07739108-563A-1F61-3F7F-0ADFE093FFC343472-024042902-DYcDB4jcUVHV2s3JFWRt5w%3D%3D',
    'buvid_fp': '05d7ff25febf982a631dd9f27dbe73ee',
    'header_theme_version': 'CLOSE',
    'CURRENT_FNVAL': '4048',
    'bsource': 'search_360',
    'PVID': '1',
    'LIVE_BUVID': 'AUTO3317144365864479',
    'b_lsid': 'B8FC6A10F_18F2C6238D0',
    'sid': 'nedbctob',
    'bili_ticket': 'eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTQ2OTU4NDgsImlhdCI6MTcxNDQzNjU4OCwicGx0IjotMX0.6hCMNMnw5BqiKzdMt4aJKKNoZJC5wAEIRG2wPCFM61Q',
    'bili_ticket_expires': '1714695788',
    'home_feed_column': '4',
    'browser_resolution': '847-937',
}

headers = {
    'authority': 'passport.bilibili.com',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'max-age=0',
    # 'cookie': 'buvid3=BD9B8A8A-BEFB-3F7B-F3EA-BE16097BEC6341653infoc; b_nut=1714358241; _uuid=BDD696FA-F8103-CD102-E6A3-110DA8589D43E41961infoc; enable_web_push=DISABLE; buvid4=07739108-563A-1F61-3F7F-0ADFE093FFC343472-024042902-DYcDB4jcUVHV2s3JFWRt5w%3D%3D; buvid_fp=05d7ff25febf982a631dd9f27dbe73ee; header_theme_version=CLOSE; CURRENT_FNVAL=4048; bsource=search_360; PVID=1; LIVE_BUVID=AUTO3317144365864479; b_lsid=B8FC6A10F_18F2C6238D0; sid=nedbctob; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTQ2OTU4NDgsImlhdCI6MTcxNDQzNjU4OCwicGx0IjotMX0.6hCMNMnw5BqiKzdMt4aJKKNoZJC5wAEIRG2wPCFM61Q; bili_ticket_expires=1714695788; home_feed_column=4; browser_resolution=847-937',
    'sec-ch-ua': '"Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'document',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-site': 'none',
    'sec-fetch-user': '?1',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36',
}

# response = requests.get('https://passport.bilibili.com/x/passport-login/web/key', cookies=cookies, headers=headers)
# t=response.json()['data']["hash"]+'123456'
t='f865fde60b4e834d123456'
n={
            "0": 195524293,
            "1": 158565141,
            "2": 219766436,
            "3": 65398251,
            "4": 102937420,
            "5": 69203429,
            "6": 229195228,
            "7": 155535494,
            "8": 118869962,
            "9": 168363975,
            "10": 230504976,
            "11": 114836340,
            "12": 250453714,
            "13": 16080191,
            "14": 174725253,
            "15": 222641222,
            "16": 158921320,
            "17": 229842942,
            "18": 238550539,
            "19": 259232370,
            "20": 33250701,
            "21": 38353497,
            "22": 99211356,
            "23": 146109207,
            "24": 2359809,
            "25": 181093027,
            "26": 70628179,
            "27": 49724046,
            "28": 31512397,
            "29": 206977674,
            "30": 178134671,
            "31": 246272638,
            "32": 40799508,
            "33": 191835611,
            "34": 123207465,
            "35": 139964706,
            "36": 58223,
            "t": 37,
            "s": 0
        }
e='0123456789abcdefghijklmnopqrstuvwxyz'
Z=[]

def process_message_for_rsa(t, e):

    r = len(t) - 1

    i = [None] *128
    while 0 <= r and 0 < e:
        n = ord(t[r])  # 获取字符的Unicode码值
        if n < 128:
            i[106+r]=n
            e=e-1
        elif 127 < n and n < 2048:
            i.append(63 & n | 128)
            i.append(n >> 6 | 192)
            e -= 2
        else:
            i.append(63 & n | 128)
            i.append(n >> 6 & 63 | 128)
            i.append(n >> 12 | 224)
            e -= 3
        r -= 1


    e=e-1
    i[e] = 0

    while e>2:
        o=[]
        while True:
            o[0]=0
            0==o[0]
            next_bytes(o)







    return i





def next_bytes(t):
    for i in range(len(t)):
        t[i]=J()


def J():
    return K_next()

def K_next():
    K=create_K()
    print(K)
    t=0

    K['i'] = (K['i'] + 1) & 255
    K['j'] = (K['j'] + K['S'][K['i']]) & 255
    t = K['S'][K['i']]
    K['S'][K['i']] = K['S'][K['j']]
    K['S'][K['j']] = t

    return K['S'][(t + K['S'][K['i']]) & 255]






def create_K():
    Z=[]
    for i in range(256):
        t=random.randint(0,65535)
        Z.append(255 & t)
        i+=1
    K={'i':0,'j':0,'S':[None]*256}


    e=0
    i=0
    r=0
    while e<256:

        K[0]=1
        K["S"][e]=e
        e += 1
    e = 0
    i = 0
    while e<256:
        i=i+K["S"][e]+Z[e % len(Z)] & 255
        r=K['S'][e]
        K['S'][e]=K['S'][i]
        K['S'][i]=r
        e=e+1
    K['i']=0
    K['j']=0
    return  K



def bitwise_or(a, b):
    return a | b


print(next_bytes())